using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;

namespace HardcoreGame.Content.Projectiles.Ammo
{
	public class StoneSlingBullet : ModProjectile
	{
		public override void SetDefaults()
		{
            Projectile.friendly = true;        
			Projectile.hostile = false;
			Projectile.DamageType = DamageClass.Ranged;
            Projectile.penetrate = 1;
            Projectile.width = 14;
            Projectile.height = 14;
        }

        public override void AI()
        {
            Projectile.rotation += Projectile.velocity.X * 0.1f;
            Projectile.velocity.Y = Projectile.velocity.Y + 0.2f;

            if (Projectile.velocity.X > 18f)
            {
                Projectile.velocity.X = 18f;
            }
            if (Projectile.velocity.X < -18f)
            {
                Projectile.velocity.X = -18f;
            }

            if (Projectile.velocity.Y > 18f)
            {
                Projectile.velocity.Y = 18f;
            }
            if (Projectile.velocity.Y < -18f)
            {
                Projectile.velocity.Y = -18f;
            }
        }

        public override void OnKill(int timeLeft)
        {
            Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
            SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
            int num4;
            for (int num524 = 0; num524 < 5; num524 = num4 + 1)
            {
                Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 1, 0f, 0f, 0, default, 1f);
                num4 = num524;
            }
        }
    }
}